package com.liyuci.core.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger2配置类【如果是测试环境或者开发环境就使用该配置类，如果是生产环境就不使用该配置类】.e
 * @author liyuci
 * @date 2017-10-20 15:22:51
 */
@Configuration
@EnableSwagger2
public class Swagger2Config
{
	/**
	 * 构建REST APIs.
	 * @author liyuci
	 * @date 2017-10-20 15:28:57
	 * @return	返回构建信息
	 */
	@Bean
	public Docket createRestApi()
	{
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage("com.liyuci")).paths(PathSelectors.any()).build();
	}

	private ApiInfo apiInfo()
	{
		return new ApiInfoBuilder().title("Eleon APIs").description("Eleon 描述").termsOfServiceUrl("http://localhost:8080/swagger-ui.html").version("1.0").build();
	}

}
